This page has been superceded by a wiki version of this example: GetchGetcharExample
import std.c.stdio;
import std.string;
void main()
{
char k;
printf("\nI'm going to ask you to press 10 keys (I promise it's painless).\n"
"Certain keys don't count, but the whole alphabet is fair game.\n\n");
for(int i=0; i<10; i++)
{
printf("Press key: %d\t", i);
k = getch();
printf("[%c]\t", k); /* print the character pressed */
printf("[%d]\n", cast(int) k); /* print ASCII code for key */
}
printf("\nThe End.\n\n");
}